package com.qiezi.user.controller;

import com.qiezi.common.exception.MessageException;
import com.qiezi.common.response.CommonResponse;
import com.qiezi.user.facade.IUserFacade;
import com.qiezi.user.request.RegistRequest;
import com.qiezi.user.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private IUserFacade userFacade;
    
    @PostMapping("/regist")
    public CommonResponse registUser(@RequestBody RegistRequest registReqeust) {
        try{
            CommonResponse response = userFacade.registUser(registReqeust);
            return response;
        } catch (MessageException e) {
            return new CommonResponse(e);
        }
    }
}
